#!/bin/sh
#author          :Ricardo de Souza Maia
#license         :GPLv3
#version         :$Id  
#encoding        :UTF-8

function user_exists(){
  if id -u $1 >/dev/null 2>&1; then
        return 0
  else
        return 1
  fi
}

function check_root()
{
  if [ $(whoami) != "root" ]
   then
    echo "Você precisa executar este programa como root."
    exit 1
  fi
}

function show_banner
{
  text_green
  echo "  _____ _____  _____ _____   "  
  echo " / ____|_   _|/ ____|  __ \  "
  echo "| |  __  | | | (___ | |__) | "
  echo "| | |_ | | |  \___ \|  ___/  "
  echo "| |__| |_| |_ ____) | |      " 
  echo " \_____|_____|_____/|_|      "     
  text_red
  echo "+-----------------------------------------------------------------+"
  echo "| Government Internet Service Provider v0.1 (beta) - GPLv3        |"
  echo "+-----------------------------------------------------------------+"
  text_normal
}

function show_error(){
{ 
text_red; echo $1; text_normal;
}

function restart_app()
{
    sleep 2
    clear
    echo -e "${BEEP}"
    show_banner
}


BEEP="\x07"
ESC="\x1b["
RED=$ESC"31;01m"
GREEN=$ESC"32;01m"
YELLOW=$ESC"33;01m"
DBLUE=$ESC"34;01m"
MAGENTA=$ESC"35;01m"
BLUE=$ESC"36;01m"
WHITE=$ESC"37;01m"
GREY=$ESC"30;01m"
RESET=$ESC"39;49;00m"
BOLD="\033[1m"

function text_bold()
{
  echo -e "\033[1m"
}

function text_blink()
{
  echo -e "\033[5m"
}

function text_normal()
{
  echo -e "\033[0m"
}

function text_green()
{
  echo -e "\033[32m"
}

function text_red()
{
  echo -e "\033[31m"
}

function text_blue()
{
  echo -e "\033[34m"
}

function text_yellow()
{
  echo -e "\033[33m"
}

function text_magenta()
{
  echo -e "\033[35m"
}

function text_cyan()
{
  echo -e "\033[36m"
}

function test_port()
{
   >/dev/tcp/localhost/$1 > /dev/null
   if [ $? -eq 0 ]; then
        return 0
   else
        return 1
   fi
}
